﻿
function Vproductname()
{
 var Name=document.getElementById("productName").value;

 if(Name.length=="")
 {
  document.getElementById("infoProductName").style.color="red";
  document.getElementById("infoProductName").innerHTML="请输入名称";
  return false;
 }
 else if(Name.length>30)
 {
  document.getElementById("infoProductName").style.color="red";
  document.getElementById("infoProductName").innerHTML="名称不能超过30个字符";
  return false;
 }
 else
 {
  document.getElementById("infoProductName").style.color="green";
  document.getElementById("infoProductName").innerHTML="名称通过";
  return true;
 }
}

function Vprice()
{
	var regu = /^\d{0,8}\.{0,1}(\d{1,4})?$/; 
	var re = new RegExp(regu);
	var price=document.getElementById("price").value;
	if(price.length=="")
	{
		document.getElementById("infoPrice").style.color="red";
		document.getElementById("infoPrice").innerHTML="请输入数据";
		return false;
	}
	
	if(re.test(price))
	{
		document.getElementById("infoPrice").style.color="green";
		document.getElementById("infoPrice").innerHTML="验证通过";
		return true;
	}
	else
	{
		document.getElementById("infoPrice").style.color="red";
		document.getElementById("infoPrice").innerHTML="请输入合法数据";
		return false;
	}
}

function Voldprice()
{
	var regu = /^\d{0,8}\.{0,1}(\d{1,4})?$/; 
	var re = new RegExp(regu);
	var price=document.getElementById("oriPrice").value;
	
	if(price.length=="")
	{
		document.getElementById("infoOldPrice").style.color="red";
		document.getElementById("infoOldPrice").innerHTML="请输入数据";
		return false;
	}
	
	if(re.test(price))
	{
		document.getElementById("infoOldPrice").style.color="green";
		document.getElementById("infoOldPrice").innerHTML="验证通过";
		return true;
	}
	else
	{
		document.getElementById("infoOldPrice").style.color="red";
		document.getElementById("infoOldPrice").innerHTML="请输入合法数据";
		return false;
	}
}

function Vdescription()
{	
	var des=document.getElementById("description").value;
	
	if(des.length>1000)
	{
		document.getElementById("infoDes").style.color="red";
		document.getElementById("infoDes").innerHTML="描述长度小于1000";
		return false;
	}
	else
	{
		document.getElementById("infoDes").style.color="green";
		document.getElementById("infoDes").innerHTML="验证通过";
		return true;
	}
}